import Vue from "vue";
import Vuex from "vuex";
import { cun, qu } from "@/utils/Storage";

Vue.use(Vuex);

const session_token = "session_keys";
export default new Vuex.Store({
  state: {
    // user: JSON.parse(window.localStorage.getItem(session_token)),
    user: qu(session_token),
  },
  mutations: {
    setUser(state, data) {
      state.user = data;
      // 将获取到的token存在session中
      // window.localStorage.setItem(session_token, JSON.stringify(data));
      cun(session_token, data);
    },
  },
  actions: {},
  modules: {},
});
